<!DOCTYPE html>
<html lang="zh-CN">
  <head>
  <meta charset="UTF-8">
  <meta 
    name="viewport"
    content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
  <meta 
    http-equiv="X-UA-Compatible" 
    content="ie=edge">
  <meta 
    name="theme-color" 
    content="#fff" 
    id="theme-color">
  <meta 
    name="description" 
    content="霜序廿的个人网站">
  <link 
    rel="icon" 
    href="https://api2.mubu.com/v3/photo/654b368e-b847-4122-982c-86d90b3f5275.jpg">
  <title>JS数据类型</title>
  
    
      <meta 
        property="og:title" 
        content="JS数据类型">
    
    
      <meta 
        property="og:url" 
        content="https://shuangxunian.github.io/2021/06/13/JSDataType/index.html">
    
    
      <meta 
        property="og:img" 
        content="https://api2.mubu.com/v3/photo/654b368e-b847-4122-982c-86d90b3f5275.jpg">
    
    
      <meta 
        property="og:img" 
        content="JS的8种数据类型">
    
    
      <meta 
        property="og:type" 
        content="article">
      <meta 
        property="og:article:published_time" 
        content="2021-06-13">
      <meta 
        property="og:article:modified_time" 
        content="2020-12-29">
      <meta 
        property="og:article:author" 
        content="霜序廿">
      
        
          <meta 
            property="og:article:tag" 
            content="js">
        
      
    
  
  <script>
    function loadScript(url, cb) {
      var script = document.createElement('script');
      script.src = url;
      if (cb) script.onload = cb;
      script.async = true;
      document.body.appendChild(script);
    }
    function loadCSS(href, data, attr) {
      var sheet = document.createElement('link');
      sheet.ref = 'stylesheet';
      sheet.href = href;
      sheet.dataset[data] = attr;
      document.head.appendChild(sheet);
    }
    function changeCSS(cssFile, data, attr) {
      var oldlink = document.querySelector(data);
      var newlink = document.createElement("link");
      newlink.setAttribute("rel", "stylesheet");
      newlink.setAttribute("href", cssFile);
      newlink.dataset.prism = attr;
      document.head.replaceChild(newlink, oldlink);
    }
  </script>
  
    
      
      
      
      
        
        
        
        <script>
          function prismThemeChange() {
            if(document.getElementById('theme-color').dataset.mode === 'dark') {
              if(document.querySelector('[data-prism]')) {
                changeCSS('/js/lib/prism/prism-tomorrow.min.css', '[data-prism]', 'prism-tomorrow');
              } else {
                loadCSS('/js/lib/prism/prism-tomorrow.min.css', 'prism', 'prism-tomorrow');
              }
            } else {
              if(document.querySelector('[data-prism]')) {
                changeCSS('/js/lib/prism/prism.min.css', '[data-prism]', 'prism');
              } else {
                loadCSS('/js/lib/prism/prism.min.css', 'prism', 'prism');
              }
            }
          }
          prismThemeChange()
        </script>
      
      
        
        <link rel="stylesheet" href="/js/lib/prism/prism-line-numbers.min.css">
      
    
  
  <script>
    // control reverse button
    var reverseDarkList = {
      dark: 'light',
      light: 'dark'
    };
    var themeColor = {
      dark: '#1c1c1e',
      light: '#fff'
    }
    // get the data of css prefers-color-scheme
    var getCssMediaQuery = function() {
      return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
    };
    // reverse current darkmode setting function
    var reverseDarkModeSetting = function() {
      var setting = localStorage.getItem('user-color-scheme');
      if(reverseDarkList[setting]) {
        setting = reverseDarkList[setting];
      } else if(setting === null) {
        setting = reverseDarkList[getCssMediaQuery()];
      } else {
        return;
      }
      localStorage.setItem('user-color-scheme', setting);
      return setting;
    };
    // apply current darkmode setting
  </script>
  
    <script>
      var setDarkmode = function(mode) {
      var setting = mode || localStorage.getItem('user-color-scheme');
      if(setting === getCssMediaQuery()) {
        document.documentElement.removeAttribute('data-user-color-scheme');
        localStorage.removeItem('user-color-scheme');
        document.getElementById('theme-color').content = themeColor[setting];
        document.getElementById('theme-color').dataset.mode = setting;
        prismThemeChange();
      } else if(reverseDarkList[setting]) {
        document.documentElement.setAttribute('data-user-color-scheme', setting);
        document.getElementById('theme-color').content = themeColor[setting];
        document.getElementById('theme-color').dataset.mode = setting;
        prismThemeChange();
      } else {
        document.documentElement.removeAttribute('data-user-color-scheme');
        localStorage.removeItem('user-color-scheme');
        document.getElementById('theme-color').content = themeColor[getCssMediaQuery()];
        document.getElementById('theme-color').dataset.mode = getCssMediaQuery();
        prismThemeChange();
      }
    };
    setDarkmode();
    </script>
  
  
  <link rel="preload" href="//at.alicdn.com/t/font_1946621_i1kgafibvw.css" as="style" >
  <link rel="preload" href="//at.alicdn.com/t/font_1952792_89b4ac4k4up.css" as="style" >
  
  
    <link rel="preload" href="/js/lib/lightbox/baguetteBox.min.js" as="script">
    <link rel="preload" href="/js/lib/lightbox/baguetteBox.min.css" as="style" >
  
  
    <link rel="preload" href="/js/lib/lozad.min.js" as="script">
  
  
  
  
  
  
  
  <link rel="stylesheet" href="/css/main.css">
  
  <link rel="stylesheet" href="//at.alicdn.com/t/font_1946621_i1kgafibvw.css">
  
  <link rel="stylesheet" href="//at.alicdn.com/t/font_1952792_89b4ac4k4up.css">
  
    <link rel="stylesheet" href="/js/lib/lightbox/baguetteBox.min.css">
  
<meta name="generator" content="Hexo 5.4.0"></head>

  <body>
    <div class="wrapper">
       
      <nav class="navbar">
  <div class="navbar-logo">
    <span class="navbar-logo-main">
      
        <img 
          class="navbar-logo-img" 
          src="https://api2.mubu.com/v3/photo/654b368e-b847-4122-982c-86d90b3f5275.jpg" 
          alt="blog logo">
      
      <span class="navbar-logo-dsc">霜序廿的个人网站</span>
    </span>
  </div>
  <div class="navbar-menu">
    
      <a 
        href="/" 
        class="navbar-menu-item">
        
          首页
        
      </a>
    
      <a 
        href="/archives" 
        class="navbar-menu-item">
        
          归档
        
      </a>
    
      <a 
        href="/tags" 
        class="navbar-menu-item">
        
          标签
        
      </a>
    
      <a 
        href="/categories" 
        class="navbar-menu-item">
        
          分类
        
      </a>
    
      <a 
        href="/about" 
        class="navbar-menu-item">
        
          关于
        
      </a>
    
      <a 
        href="/links" 
        class="navbar-menu-item">
        
          友链
        
      </a>
    
    <a 
      class="navbar-menu-item darknavbar" 
      id="dark">
      <i class="iconfont icon-weather"></i>
    </a>
    <a 
      class="navbar-menu-item searchnavbar" 
      id="search">
      <i 
        class="iconfont icon-search" 
        style="font-size: 1.2rem; font-weight: 400;">
      </i>
    </a>
  </div>
</nav> 
      
      <div 
        id="local-search" 
        style="display: none">
        <input
          class="navbar-menu-item"
          id="search-input"
          placeholder="请输入搜索内容..." />
        <div id="search-content"></div>
      </div>
      
      <div class="section-wrap">
        <div class="container">
          <div class="columns">
            <main class="main-column">
<article class="card card-content">
  <header>
    <h1 class="post-title">
      JS数据类型
    </h1>
  </header>
  <div class="post-meta post-show-meta">
    <time datetime="2021-06-13T13:48:56.160Z">
      <i 
        class="iconfont icon-calendar" 
        style="margin-right: 2px;">
      </i>
      <span>2021-06-13</span>
    </time>
    
      <span class="dot"></span>
      
        <a 
          href="/categories/%E6%8A%80%E6%9C%AF%E6%96%87%E7%AB%A0/" 
          class="post-meta-link">
          技术文章
        </a>
      
    
    
      <span class="dot"></span>
      <span>1.5k 字</span>
    
  </div>
  
    <div 
      class="post-meta post-show-meta" 
      style="margin-top: -10px;">
      <div style="display: flex; align-items: center;">
        <i 
          class="iconfont icon-biaoqian" 
          style="margin-right: 2px; font-size: 1.15rem;">
        </i>
        
          
          <a 
            href="/tags/js/" 
            class="post-meta-link">
            js
          </a>
        
      </div>
    </div>
  
  </header>
  <div 
    id="section" 
    class="post-content">
    <h2 id="JS数据类型：基础概念"><a href="#JS数据类型：基础概念" class="headerlink" title="JS数据类型：基础概念"></a>JS数据类型：基础概念</h2><p>请注意：JS的数据类型有8种。</p>
<p>在ES5的时候，我们认知的数据类型确实是 6种：Number、String、Boolean、undefined、object、Null。</p>
<p>ES6 中新增了一种 Symbol 。这种类型的对象永不相等，即始创建的时候传入相同的值，可以解决属性名冲突的问题，做为标记。</p>
<p>谷歌67版本中还出现了一种 bigInt。是指安全存储、操作大整数。（但是很多人不把这个做为一个类型）。</p>
<h2 id="JS数据类型：JS-的数据类型有几种？"><a href="#JS数据类型：JS-的数据类型有几种？" class="headerlink" title="JS数据类型：JS 的数据类型有几种？"></a>JS数据类型：JS 的数据类型有几种？</h2><p>8种。Number、String、Boolean、Null、undefined、object、symbol、bigInt。</p>
<h2 id="JS数据类型：Object-中包含了哪几种类型？"><a href="#JS数据类型：Object-中包含了哪几种类型？" class="headerlink" title="JS数据类型：Object 中包含了哪几种类型？"></a>JS数据类型：Object 中包含了哪几种类型？</h2><p>其中包含了Data、function、Array等。这三种是常规用的。</p>
<h2 id="JS数据类型：JS的基本类型和引用类型有哪些呢？"><a href="#JS数据类型：JS的基本类型和引用类型有哪些呢？" class="headerlink" title="JS数据类型：JS的基本类型和引用类型有哪些呢？"></a>JS数据类型：JS的基本类型和引用类型有哪些呢？</h2><p>基本类型（单类型）：除Object。 String、Number、boolean、null、undefined。<br>引用类型：object。里面包含的 function、Array、Date。</p>
<h2 id="JS数据类型：JS-中-typeof-输出分别是什么？"><a href="#JS数据类型：JS-中-typeof-输出分别是什么？" class="headerlink" title="JS数据类型：JS 中 typeof 输出分别是什么？"></a>JS数据类型：JS 中 typeof 输出分别是什么？</h2><table>
<thead>
<tr>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody><tr>
<td>String</td>
<td>String</td>
<td>字符串</td>
</tr>
<tr>
<td>Number</td>
<td>Number</td>
<td>数据类型</td>
</tr>
<tr>
<td>Boolean</td>
<td>Boolean</td>
<td>布尔型</td>
</tr>
<tr>
<td>Undefined</td>
<td>Undefined</td>
<td>没有初始化、定义的值</td>
</tr>
<tr>
<td>Null</td>
<td>Object</td>
<td>不存在的对象</td>
</tr>
<tr>
<td>NaN</td>
<td>Number</td>
<td>Number 中的特殊数值</td>
</tr>
<tr>
<td>Object</td>
<td>Function</td>
<td></td>
</tr>
</tbody></table>
<h2 id="Number-‘as’-NaN"><a href="#Number-‘as’-NaN" class="headerlink" title="Number(‘as’) == NaN ?"></a>Number(‘as’) == NaN ?</h2><p>肯定是false， Number(‘as’) 输出 NaN。<br>注：用 isNaN（） 检测是否是非数值型。 js 规定的NaN 不等于NaN。</p>
<h2 id="Number-‘123’-NaN-？"><a href="#Number-‘123’-NaN-？" class="headerlink" title="Number(‘123’) == NaN ？"></a>Number(‘123’) == NaN ？</h2><p>肯定是false，Number(‘123’) 输出 123。</p>
<h2 id="JS数据类型：如何判断数据类型？"><a href="#JS数据类型：如何判断数据类型？" class="headerlink" title="JS数据类型：如何判断数据类型？"></a>JS数据类型：如何判断数据类型？</h2><ol>
<li>typeof 操作符（通用：上面有内容有讲到）</li>
<li>toString()<br> 作用：其他类型转成 string 的方法<br> 支持：number、boolean、string、object<br> 不支持：null 、undefined</li>
<li>toLocaleString<br> 把数组转成本地字符串</li>
<li>检测数组类型的方法<ul>
<li>instanceof  操作符</li>
<li>对象的 constructor 属性</li>
<li>Array.isArray()检验值是否为数组</li>
</ul>
</li>
</ol>
<h2 id="JS数据类型：null-和-undefined-有什么区别？"><a href="#JS数据类型：null-和-undefined-有什么区别？" class="headerlink" title="JS数据类型：null 和 undefined 有什么区别？"></a>JS数据类型：null 和 undefined 有什么区别？</h2><p>Null 只有一个值，是 null。不存在的对象。<br>Undefined 只有一个值，是undefined。没有初始化。undefined 是从 null 中派生出来的。<br>简单理解就是：undefined 是没有定义的，null 是定义了但是为空。</p>
<h2 id="JS数据类型：null-不存在的原因是什么？如何解决？"><a href="#JS数据类型：null-不存在的原因是什么？如何解决？" class="headerlink" title="JS数据类型：null 不存在的原因是什么？如何解决？"></a>JS数据类型：null 不存在的原因是什么？如何解决？</h2><p>不存在的原因是：<br>    1. 方法不存在<br>    2. 对象不存在<br>    3. 字符串变量不存在<br>    4. 接口类型对象没初始化 </p>
<p>解决方法：<br>    做判断处理的时候，放在设定值的最前面</p>
<h2 id="JS数据类型：-和-有什么区别，什么场景下使用？"><a href="#JS数据类型：-和-有什么区别，什么场景下使用？" class="headerlink" title="JS数据类型：== 和 === 有什么区别，什么场景下使用？"></a>JS数据类型：== 和 === 有什么区别，什么场景下使用？</h2><ul>
<li>==表示相同。<br>  比较的是物理地址，相当于比较两个对象的 hashCode ，肯定不相等的。<br>  类型不同，值也可能相等。</li>
<li>===表示严格相同。<br>  例：同为 null／undefined ，相等。</li>
</ul>
<p>简单理解就是 == 就是先比较数据类型是否一样。=== 类型不同直接就是 false。</p>
<h2 id="JS数据类型：对象可以比较地？"><a href="#JS数据类型：对象可以比较地？" class="headerlink" title="JS数据类型：对象可以比较地？"></a>JS数据类型：对象可以比较地？</h2><p>对象是可以比较，遍历比较key 和 value就行， Object.is(value1, value2)。</p>
<h2 id="JS数据类型：总结"><a href="#JS数据类型：总结" class="headerlink" title="JS数据类型：总结"></a>JS数据类型：总结</h2><ol>
<li><p>Undefined 类型<br> 只有一个值。在使用var 声明变量但未对其加初始化时，这个变量就是undefined。</p>
</li>
<li><p>Null 类型<br> 只有一个值。null是表示一个空对象指针，这也是typeof操作符检测 null 值时会返回 object 的原因。</p>
</li>
<li><p>Boolean 类型<br> 使用最多的一个类型，有两个字面值，分别是true、false。true不一定等于1,false不一定等于0。<br> boolean类型的字面值是区分大小写的。True和False是标识符</p>
</li>
<li><p>Number 类型<br> 数字类型，表示数据的整数和浮点数。某些语言中也称为“双精度值”。</p>
 <pre class="line-numbers language-javascript" data-language="javascript"><code class="language-javascript"><span class="token keyword">var</span> intNum <span class="token operator">=</span> <span class="token number">55</span><span class="token punctuation">;</span>    <span class="token comment">//十进制</span>
<span class="token keyword">var</span> num <span class="token operator">=</span> <span class="token number">012</span><span class="token punctuation">;</span>      <span class="token comment">//八进制</span>
<span class="token keyword">var</span> octalNum <span class="token operator">=</span> <span class="token number">0x23</span><span class="token punctuation">;</span><span class="token comment">//十六进制</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span></span></code></pre></li>
<li><p>String 类型<br> 字符串可以有单引号、双引号表示。字符串是不可变的，一旦创建，值就不能改变<br> 要改变某个变量保存的字符串，首先要销毁原来的字符串，然后于用另一个包含的字符串填充该变量。<br> 注）toString()可以输出二进制、八进制、十进制，十六进制。null和undefined没有toString()方法，用String函数不返回这两个值的字面量。</p>
</li>
<li><p>Object 类型<br> ECMAjavascript中的对象其实就是一组数据和功能的集合。对象可以通过执行new操作符后跟要创建的对象类型的名称来创建。创建object类型的实例并为其添加属性（或）方法，就可以自定义创建对象。如：var o = new Object( );<br> object 的每个实例都有下列属性和方法：</p>
<ul>
<li>constructor：保存着用于创建当前对象的函数。（构造函数)constructor就是object();</li>
<li>hasOwnProperty(propertyName):用于检查给定的当前属性在当前对象实例中）而不是在实例原型中）是否存在。其中，作为参数的属性名（propertyName)必须以字符串形式指定（例如：o.hasOwnProperty(“name”))。</li>
<li>isPrototypeOf(object):用于检查传入的对象是否是传入对象原型。</li>
<li>propertyIsEnumerable(propertyName):用于检查给定属性是否能够用for-in语句。与hasOwnProperty（）方法一样，作为参数的属性名必须以字符串形式指定。</li>
<li>toLocaleString( ):返回对象的字符串表示，该字符串与执行环境的地区对应。</li>
<li>toString( ):返回对象的字符串表示。</li>
<li>valueOf( ):返回对象的字符串、数值或者布尔值表示。通常与toString( )方法的返回值得相同。</li>
</ul>
<p> ECMAJS中object是所有对象的基础，因些所有对象都具有这些基本的属性和方法。</p>
</li>
<li><p>Symbol 类型<br> Symbol 类型的对象永远不相等，即便创建的时候传入相同的值。因此，可以用解决属性名冲突的问题（适用于多少编码），做为标记。<br> 这是 es6 新增的数据类型。</p>
</li>
<li><p>BigInt 类型<br> Javascript 中的任意精度整数，可以安全存储和操作大整数。即始超出 Number 能够表示的安全整数范围。是 chrome 67中的新功能。</p>
</li>
</ol>
<h2 id="参考链接"><a href="#参考链接" class="headerlink" title="参考链接"></a>参考链接</h2><p><a target="_blank" rel="noopener" href="https://blog.csdn.net/u013592575/article/details/95087953">JS基础篇1：数据类型（8种）</a></p>

  </div>
  <div>
    
  </div>
</article>
<div class="nav">
  
    <div class="nav-item-prev">
      <a 
        href="/2021/06/13/JSFocusEvents/" 
        class="nav-link">
        <i class="iconfont icon-left nav-prev-icon"></i>
        <div>
          <div class="nav-label">上一篇</div>
          
            <div class="nav-title">js焦点事件:onfocus、onblur、focus()、blur()、select() </div>
          
        </div>
      </a>
    </div>
  
  
    <div class="nav-item-next">
      <a 
        href="/2021/06/13/jsCloneIsImplemented/" 
        class="nav-link">
        <div>
          <div class="nav-label">下一篇</div>
          
            <div class="nav-title">实现js的clone函数 </div>
          
        </div>
        <i class="iconfont icon-right nav-next-icon"></i>
      </a>
    </div>
  
</div>

<div 
  class="card card-content toc-card" 
  id="mobiletoc">
  <div class="toc-header">
  <i 
    class="iconfont icon-menu" 
    style="padding-right: 2px;">
  </i>目录
</div>
<ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9A%E5%9F%BA%E7%A1%80%E6%A6%82%E5%BF%B5"><span class="toc-text">JS数据类型：基础概念</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9AJS-%E7%9A%84%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%E6%9C%89%E5%87%A0%E7%A7%8D%EF%BC%9F"><span class="toc-text">JS数据类型：JS 的数据类型有几种？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9AObject-%E4%B8%AD%E5%8C%85%E5%90%AB%E4%BA%86%E5%93%AA%E5%87%A0%E7%A7%8D%E7%B1%BB%E5%9E%8B%EF%BC%9F"><span class="toc-text">JS数据类型：Object 中包含了哪几种类型？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9AJS%E7%9A%84%E5%9F%BA%E6%9C%AC%E7%B1%BB%E5%9E%8B%E5%92%8C%E5%BC%95%E7%94%A8%E7%B1%BB%E5%9E%8B%E6%9C%89%E5%93%AA%E4%BA%9B%E5%91%A2%EF%BC%9F"><span class="toc-text">JS数据类型：JS的基本类型和引用类型有哪些呢？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9AJS-%E4%B8%AD-typeof-%E8%BE%93%E5%87%BA%E5%88%86%E5%88%AB%E6%98%AF%E4%BB%80%E4%B9%88%EF%BC%9F"><span class="toc-text">JS数据类型：JS 中 typeof 输出分别是什么？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Number-%E2%80%98as%E2%80%99-NaN"><span class="toc-text">Number(‘as’) &#x3D;&#x3D; NaN ?</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Number-%E2%80%98123%E2%80%99-NaN-%EF%BC%9F"><span class="toc-text">Number(‘123’) &#x3D;&#x3D; NaN ？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9A%E5%A6%82%E4%BD%95%E5%88%A4%E6%96%AD%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9F"><span class="toc-text">JS数据类型：如何判断数据类型？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9Anull-%E5%92%8C-undefined-%E6%9C%89%E4%BB%80%E4%B9%88%E5%8C%BA%E5%88%AB%EF%BC%9F"><span class="toc-text">JS数据类型：null 和 undefined 有什么区别？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9Anull-%E4%B8%8D%E5%AD%98%E5%9C%A8%E7%9A%84%E5%8E%9F%E5%9B%A0%E6%98%AF%E4%BB%80%E4%B9%88%EF%BC%9F%E5%A6%82%E4%BD%95%E8%A7%A3%E5%86%B3%EF%BC%9F"><span class="toc-text">JS数据类型：null 不存在的原因是什么？如何解决？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9A-%E5%92%8C-%E6%9C%89%E4%BB%80%E4%B9%88%E5%8C%BA%E5%88%AB%EF%BC%8C%E4%BB%80%E4%B9%88%E5%9C%BA%E6%99%AF%E4%B8%8B%E4%BD%BF%E7%94%A8%EF%BC%9F"><span class="toc-text">JS数据类型：&#x3D;&#x3D; 和 &#x3D;&#x3D;&#x3D; 有什么区别，什么场景下使用？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9A%E5%AF%B9%E8%B1%A1%E5%8F%AF%E4%BB%A5%E6%AF%94%E8%BE%83%E5%9C%B0%EF%BC%9F"><span class="toc-text">JS数据类型：对象可以比较地？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9A%E6%80%BB%E7%BB%93"><span class="toc-text">JS数据类型：总结</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8F%82%E8%80%83%E9%93%BE%E6%8E%A5"><span class="toc-text">参考链接</span></a></li></ol>
</div></main>
            <aside class="left-column">
              
              <div class="card card-author">
                
  <img 
    src="https://api2.mubu.com/v3/photo/654b368e-b847-4122-982c-86d90b3f5275.jpg" 
    class="author-img" 
    alt="author avatar">

<p class="author-name">霜序廿</p>
<p class="author-description">无限进步</p>
<div class="author-message">
  <a 
    class="author-posts-count" 
    href="/archives">
    <span>253</span>
    <span>文章</span>
  </a>
  <a 
    class="author-categories-count" 
    href="/categories">
    <span>6</span>
    <span>分类</span>
  </a>
  <a 
    class="author-tags-count" 
    href="/tags">
    <span>51</span>
    <span>标签</span>
  </a>
</div>

  <div class="author-card-society">
    
      <div class="author-card-society-icon">
        <a target="_blank" rel="noopener" href="https://github.com/shuangxunian">
          <i class="iconfont icon-github society-icon"></i>
        </a>
      </div>
    
      <div class="author-card-society-icon">
        <a target="_blank" rel="noopener" href="https://space.bilibili.com/391117803">
          <i class="iconfont icon-bilibili society-icon"></i>
        </a>
      </div>
    
  </div>

              </div>
               <div class="sticky-tablet">
  
  
    <article class="display-when-two-columns spacer">
      <div class="card card-content toc-card">
        <div class="toc-header">
  <i 
    class="iconfont icon-menu" 
    style="padding-right: 2px;">
  </i>目录
</div>
<ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9A%E5%9F%BA%E7%A1%80%E6%A6%82%E5%BF%B5"><span class="toc-text">JS数据类型：基础概念</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9AJS-%E7%9A%84%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%E6%9C%89%E5%87%A0%E7%A7%8D%EF%BC%9F"><span class="toc-text">JS数据类型：JS 的数据类型有几种？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9AObject-%E4%B8%AD%E5%8C%85%E5%90%AB%E4%BA%86%E5%93%AA%E5%87%A0%E7%A7%8D%E7%B1%BB%E5%9E%8B%EF%BC%9F"><span class="toc-text">JS数据类型：Object 中包含了哪几种类型？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9AJS%E7%9A%84%E5%9F%BA%E6%9C%AC%E7%B1%BB%E5%9E%8B%E5%92%8C%E5%BC%95%E7%94%A8%E7%B1%BB%E5%9E%8B%E6%9C%89%E5%93%AA%E4%BA%9B%E5%91%A2%EF%BC%9F"><span class="toc-text">JS数据类型：JS的基本类型和引用类型有哪些呢？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9AJS-%E4%B8%AD-typeof-%E8%BE%93%E5%87%BA%E5%88%86%E5%88%AB%E6%98%AF%E4%BB%80%E4%B9%88%EF%BC%9F"><span class="toc-text">JS数据类型：JS 中 typeof 输出分别是什么？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Number-%E2%80%98as%E2%80%99-NaN"><span class="toc-text">Number(‘as’) &#x3D;&#x3D; NaN ?</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Number-%E2%80%98123%E2%80%99-NaN-%EF%BC%9F"><span class="toc-text">Number(‘123’) &#x3D;&#x3D; NaN ？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9A%E5%A6%82%E4%BD%95%E5%88%A4%E6%96%AD%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9F"><span class="toc-text">JS数据类型：如何判断数据类型？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9Anull-%E5%92%8C-undefined-%E6%9C%89%E4%BB%80%E4%B9%88%E5%8C%BA%E5%88%AB%EF%BC%9F"><span class="toc-text">JS数据类型：null 和 undefined 有什么区别？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9Anull-%E4%B8%8D%E5%AD%98%E5%9C%A8%E7%9A%84%E5%8E%9F%E5%9B%A0%E6%98%AF%E4%BB%80%E4%B9%88%EF%BC%9F%E5%A6%82%E4%BD%95%E8%A7%A3%E5%86%B3%EF%BC%9F"><span class="toc-text">JS数据类型：null 不存在的原因是什么？如何解决？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9A-%E5%92%8C-%E6%9C%89%E4%BB%80%E4%B9%88%E5%8C%BA%E5%88%AB%EF%BC%8C%E4%BB%80%E4%B9%88%E5%9C%BA%E6%99%AF%E4%B8%8B%E4%BD%BF%E7%94%A8%EF%BC%9F"><span class="toc-text">JS数据类型：&#x3D;&#x3D; 和 &#x3D;&#x3D;&#x3D; 有什么区别，什么场景下使用？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9A%E5%AF%B9%E8%B1%A1%E5%8F%AF%E4%BB%A5%E6%AF%94%E8%BE%83%E5%9C%B0%EF%BC%9F"><span class="toc-text">JS数据类型：对象可以比较地？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9A%E6%80%BB%E7%BB%93"><span class="toc-text">JS数据类型：总结</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8F%82%E8%80%83%E9%93%BE%E6%8E%A5"><span class="toc-text">参考链接</span></a></li></ol>
      </div>
    </article>
  
  
  <article class="card card-content categories-widget">
    <div class="categories-card">
  <div class="categories-header">
    <i 
      class="iconfont icon-fenlei" 
      style="padding-right: 2px;">
    </i>分类
  </div>
  <div class="categories-list">
    
      <a href="/categories/%E6%8A%80%E6%9C%AF%E6%96%87%E7%AB%A0/">
        <div class="categories-list-item">
          技术文章
          <span class="categories-list-item-badge">218</span>
        </div>
      </a>
    
      <a href="/categories/%E5%85%B6%E4%BB%96/">
        <div class="categories-list-item">
          其他
          <span class="categories-list-item-badge">16</span>
        </div>
      </a>
    
      <a href="/categories/%E6%97%85%E6%B8%B8/">
        <div class="categories-list-item">
          旅游
          <span class="categories-list-item-badge">1</span>
        </div>
      </a>
    
      <a href="/categories/%E7%AE%97%E6%B3%95/">
        <div class="categories-list-item">
          算法
          <span class="categories-list-item-badge">8</span>
        </div>
      </a>
    
      <a href="/categories/%E8%80%83%E8%AF%95/">
        <div class="categories-list-item">
          考试
          <span class="categories-list-item-badge">8</span>
        </div>
      </a>
    
      <a href="/categories/%E9%98%85%E8%AF%BB/">
        <div class="categories-list-item">
          阅读
          <span class="categories-list-item-badge">1</span>
        </div>
      </a>
    
  </div>
</div>
  </article>
  
  <article class="card card-content tags-widget">
    <div class="tags-card">
  <div class="tags-header">
    <i 
      class="iconfont icon-biaoqian" 
      style="padding-right: 2px;">
    </i>热门标签
  </div>
  <div class="tags-list">
    
      <a 
        href="/tags/js/" 
        title="js">
        <div class="tags-list-item">js</div>
      </a>
    
      <a 
        href="/tags/vue/" 
        title="vue">
        <div class="tags-list-item">vue</div>
      </a>
    
      <a 
        href="/tags/%E9%9D%A2%E8%AF%95/" 
        title="面试">
        <div class="tags-list-item">面试</div>
      </a>
    
      <a 
        href="/tags/css/" 
        title="css">
        <div class="tags-list-item">css</div>
      </a>
    
      <a 
        href="/tags/%E7%BD%91%E7%BB%9C/" 
        title="网络">
        <div class="tags-list-item">网络</div>
      </a>
    
      <a 
        href="/tags/%E5%85%B6%E4%BB%96/" 
        title="其他">
        <div class="tags-list-item">其他</div>
      </a>
    
      <a 
        href="/tags/%E7%AE%97%E6%B3%95/" 
        title="算法">
        <div class="tags-list-item">算法</div>
      </a>
    
      <a 
        href="/tags/%E6%B5%8F%E8%A7%88%E5%99%A8/" 
        title="浏览器">
        <div class="tags-list-item">浏览器</div>
      </a>
    
      <a 
        href="/tags/html/" 
        title="html">
        <div class="tags-list-item">html</div>
      </a>
    
      <a 
        href="/tags/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/" 
        title="操作系统">
        <div class="tags-list-item">操作系统</div>
      </a>
    
      <a 
        href="/tags/%E8%80%83%E8%AF%95/" 
        title="考试">
        <div class="tags-list-item">考试</div>
      </a>
    
      <a 
        href="/tags/%E8%BD%AF%E5%AE%9E%E5%8A%9B/" 
        title="软实力">
        <div class="tags-list-item">软实力</div>
      </a>
    
      <a 
        href="/tags/DOM/" 
        title="DOM">
        <div class="tags-list-item">DOM</div>
      </a>
    
      <a 
        href="/tags/%E8%BD%AE%E5%AD%90/" 
        title="轮子">
        <div class="tags-list-item">轮子</div>
      </a>
    
      <a 
        href="/tags/%E7%BD%91%E7%BB%9C%E5%8E%9F%E7%90%86/" 
        title="网络原理">
        <div class="tags-list-item">网络原理</div>
      </a>
    
      <a 
        href="/tags/debug/" 
        title="debug">
        <div class="tags-list-item">debug</div>
      </a>
    
  </div>
</div>
  </article>
  
  
</div>
            </aside>
            <aside class="right-column">
              <div class="sticky-widescreen">
  
  
    <article class="card card-content toc-card">
      <div class="toc-header">
  <i 
    class="iconfont icon-menu" 
    style="padding-right: 2px;">
  </i>目录
</div>
<ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9A%E5%9F%BA%E7%A1%80%E6%A6%82%E5%BF%B5"><span class="toc-text">JS数据类型：基础概念</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9AJS-%E7%9A%84%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%E6%9C%89%E5%87%A0%E7%A7%8D%EF%BC%9F"><span class="toc-text">JS数据类型：JS 的数据类型有几种？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9AObject-%E4%B8%AD%E5%8C%85%E5%90%AB%E4%BA%86%E5%93%AA%E5%87%A0%E7%A7%8D%E7%B1%BB%E5%9E%8B%EF%BC%9F"><span class="toc-text">JS数据类型：Object 中包含了哪几种类型？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9AJS%E7%9A%84%E5%9F%BA%E6%9C%AC%E7%B1%BB%E5%9E%8B%E5%92%8C%E5%BC%95%E7%94%A8%E7%B1%BB%E5%9E%8B%E6%9C%89%E5%93%AA%E4%BA%9B%E5%91%A2%EF%BC%9F"><span class="toc-text">JS数据类型：JS的基本类型和引用类型有哪些呢？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9AJS-%E4%B8%AD-typeof-%E8%BE%93%E5%87%BA%E5%88%86%E5%88%AB%E6%98%AF%E4%BB%80%E4%B9%88%EF%BC%9F"><span class="toc-text">JS数据类型：JS 中 typeof 输出分别是什么？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Number-%E2%80%98as%E2%80%99-NaN"><span class="toc-text">Number(‘as’) &#x3D;&#x3D; NaN ?</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Number-%E2%80%98123%E2%80%99-NaN-%EF%BC%9F"><span class="toc-text">Number(‘123’) &#x3D;&#x3D; NaN ？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9A%E5%A6%82%E4%BD%95%E5%88%A4%E6%96%AD%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9F"><span class="toc-text">JS数据类型：如何判断数据类型？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9Anull-%E5%92%8C-undefined-%E6%9C%89%E4%BB%80%E4%B9%88%E5%8C%BA%E5%88%AB%EF%BC%9F"><span class="toc-text">JS数据类型：null 和 undefined 有什么区别？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9Anull-%E4%B8%8D%E5%AD%98%E5%9C%A8%E7%9A%84%E5%8E%9F%E5%9B%A0%E6%98%AF%E4%BB%80%E4%B9%88%EF%BC%9F%E5%A6%82%E4%BD%95%E8%A7%A3%E5%86%B3%EF%BC%9F"><span class="toc-text">JS数据类型：null 不存在的原因是什么？如何解决？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9A-%E5%92%8C-%E6%9C%89%E4%BB%80%E4%B9%88%E5%8C%BA%E5%88%AB%EF%BC%8C%E4%BB%80%E4%B9%88%E5%9C%BA%E6%99%AF%E4%B8%8B%E4%BD%BF%E7%94%A8%EF%BC%9F"><span class="toc-text">JS数据类型：&#x3D;&#x3D; 和 &#x3D;&#x3D;&#x3D; 有什么区别，什么场景下使用？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9A%E5%AF%B9%E8%B1%A1%E5%8F%AF%E4%BB%A5%E6%AF%94%E8%BE%83%E5%9C%B0%EF%BC%9F"><span class="toc-text">JS数据类型：对象可以比较地？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#JS%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%EF%BC%9A%E6%80%BB%E7%BB%93"><span class="toc-text">JS数据类型：总结</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8F%82%E8%80%83%E9%93%BE%E6%8E%A5"><span class="toc-text">参考链接</span></a></li></ol>
    </article>
  
  
  <article class="card card-content">
    <div class="recent-posts-card">
  <div class="recent-posts-header">
    <i 
      class="iconfont icon-wenzhang_huaban" 
      style="padding-right: 2px;">
    </i>最近文章
  </div>
  <div class="recent-posts-list">
    
      <div class="recent-posts-item">
        <div class="recent-posts-item-title">2022-05-01</div>
        <a href="/2022/05/01/typescriptHome/"><div class="recent-posts-item-content">typescript</div></a>
      </div>
    
      <div class="recent-posts-item">
        <div class="recent-posts-item-title">2022-01-15</div>
        <a href="/2022/01/15/javaScriptTheVariousWaysAndAdvantagesAndDisadvantagesOfDeepInheritance/"><div class="recent-posts-item-content">JavaScript深入之继承的多种方式和优缺点</div></a>
      </div>
    
      <div class="recent-posts-item">
        <div class="recent-posts-item-title">2022-01-15</div>
        <a href="/2022/01/15/javaScriptGoFromPrototypeToPrototypeChain/"><div class="recent-posts-item-content">JavaScript深入之从原型到原型链</div></a>
      </div>
    
      <div class="recent-posts-item">
        <div class="recent-posts-item-title">2022-01-15</div>
        <a href="/2022/01/15/javaScriptMemoryLeakTutorial/"><div class="recent-posts-item-content">JavaScript 内存泄漏教程</div></a>
      </div>
    
  </div>
</div>
  </article>
  
  
  
  <article class="card card-content">
    <div class="recent-posts-card">
  <div class="recent-posts-header">
    关注嘉然！顿顿解馋！
  </div>
  <div class="recent-posts-list">
    
      <img 
        src="https://api2.mubu.com/v3/document_image/2697c6ae-10ee-41a3-9099-304bdb252d31-3807603.jpg" 
        class="myadd-img" 
        alt="author avatar">
    
  </div>
</div>
  </article>
</div>
            </aside>
          </div>
        </div>
      </div>
    </div>
     
    <footer class="footer">
  <div class="footer-container">
    <div>
      <div class="footer-dsc">
        <span>
          Copyright ©
          
            2020 -
          
          2022
        </span>
        &nbsp;
        <a 
          href="/" 
          class="footer-link">
          霜序廿的个人网站
        </a>
      </div>
    </div>

    
      <div class="footer-dsc">
        
          Powered by
          <a 
            href="https://hexo.io/" 
            class="footer-link" 
            target="_blank" 
            rel="nofollow noopener noreferrer">
            &nbsp;Hexo
          </a>
        
        
          <span>&nbsp;|&nbsp;</span>
        
        
          Theme -
          <a 
            href="https://github.com/theme-kaze" 
            class="footer-link" 
            target="_blank"
            rel="nofollow noopener noreferrer">
            &nbsp;Kaze
          </a>
        
      </div>
    
    
    
    
</footer> 
    
  <a 
    role="button" 
    id="scrollbutton" 
    class="basebutton" 
    aria-label="回到顶部">
    <i class="iconfont icon-arrowleft button-icon"></i>
  </a>

<a 
  role="button" 
  id="menubutton" 
  class="basebutton">
  <i class="iconfont icon-menu button-icon"></i>
</a>
<a 
  role="button" 
  id="popbutton" 
  class="basebutton" 
  aria-label="控制中心">
  <i class="iconfont icon-expand button-icon"></i>
</a>
<a 
  role="button" 
  id="darkbutton" 
  class="basebutton darkwidget" 
  aria-label="夜色模式">
  <i class="iconfont icon-weather button-icon"></i>
</a>
<a 
  role="button" 
  id="searchbutton" 
  class="basebutton searchwidget" 
  aria-label="搜索">
  <i class="iconfont icon-search button-icon"></i>
</a> 
     
     
     
      <script>
  var addImgLayout = function () {
    var img = document.querySelectorAll('.post-content img')
    var i
    for (i = 0; i < img.length; i++) {
      var wrapper = document.createElement('a')
      wrapper.setAttribute('href', img[i].getAttribute('data-src'))
      wrapper.setAttribute('aria-label', 'illustration')
      wrapper.style.cssText =
        'width: 100%; display: flex; justify-content: center;'
      if (img[i].alt) wrapper.dataset.caption = img[i].alt
      wrapper.dataset.nolink = true
      img[i].before(wrapper)
      wrapper.append(img[i])
      var divWrap = document.createElement('div')
      divWrap.classList.add('gallery')
      wrapper.before(divWrap)
      divWrap.append(wrapper)
    }
    baguetteBox.run('.gallery')
  }
</script>
<script>
  loadScript(
    "/js/lib/lightbox/baguetteBox.min.js",
    addImgLayout
  )
</script>
 
     
     
    <script src="/js/main.js"></script> 
     
    
      <script>
        var addLazyload = function () {
          var observer = lozad('.lozad', {
            load: function (el) {
              el.srcset = el.getAttribute('data-src')
            },
            loaded: function (el) {
              el.classList.add('loaded')
            },
          })
          observer.observe()
        }
      </script>
      <script>
        loadScript('/js/lib/lozad.min.js', addLazyload)
      </script>
     
    
    
  </body>
</html>
